home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / E / prefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  8.8 KB  |  304 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/nodes.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/types.h>
  7. #include <intuition/intuition.h>        // intuition
  8. #include <intuition/gadgetclass.h>
  9. #include <libraries/gadtools.h>         // libraries
  10. #include <libraries/reqtools.h>
  11. #include <clib/exec_protos.h>           // protos
  12. #include <clib/intuition_protos.h>
  13. #include <clib/reqtools_protos.h>
  14. #include <pragmas/exec_pragmas.h>       // pragmas
  15. #include <pragmas/intuition_pragmas.h>
  16. #include <pragmas/gadtools_pragmas.h>
  17. #include <pragmas/reqtools_pragmas.h>
  18.  
  19. #include <string.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <ctype.h>
  23.  
  24. #include "DEV_IE:Generators/defs.h"
  25. #include "DEV_IE:Include/IEditor.h"
  26. #include "DEV_IE:Generators/C/Config.h"
  27. #include "DEV_IE:Generators/C/Protos.h"
  28. ///
  29. /// Data
  30. static ULONG CheckedTag[] = { GTCB_Checked, 0, TAG_END };
  31. ///
  32.  
  33. /// Config
  34. void Config( __A0 struct IE_Data *IE )
  35. {
  36.     struct Window  *Wnd = NULL;
  37.     struct Gadget  *GList = NULL, *Gadgets[ Conf_CNT ];
  38.     UBYTE           Back;
  39.     BOOL            ret;
  40.  
  41.     if( OpenConfWindow( &Wnd, &GList, &Gadgets[0], IE )) {
  42.  
  43.     (*IE->Functions->Status)( "Cannot open my window!", TRUE, 0 );
  44.  
  45.     } else {
  46.  
  47.     Back = IE->C_Prefs;
  48.  
  49.     IE->C_Prefs = ~IE->C_Prefs;
  50.     TemplateKeyPressed( Wnd, Gadgets, IE, NULL );
  51.     ClickKeyPressed( Wnd, Gadgets, IE, NULL );
  52.     MsgKeyPressed( Wnd, Gadgets, IE, NULL );
  53.     HandlerKeyPressed( Wnd, Gadgets, IE, NULL );
  54.     KeyHandlerKeyPressed( Wnd, Gadgets, IE, NULL );
  55.     ToLowerKeyPressed( Wnd, Gadgets, IE, NULL );
  56.     SmartStrKeyPressed( Wnd, Gadgets, IE, NULL );
  57.     NewTmpKeyPressed( Wnd, Gadgets, IE, NULL );
  58.     IE->C_Prefs = Back;
  59.  
  60.     GT_SetGadgetAttrs( Gadgets[ GD_Chip ], Wnd, NULL,
  61.                GTST_String, IE->ChipString, TAG_END );
  62.  
  63.     do {
  64.         WaitPort( Wnd->UserPort );
  65.         ret = HandleConfIDCMP( Wnd, &Gadgets[0], IE );
  66.     } while ( ret == 0 );
  67.  
  68.     if( ret > 0 )
  69.         IE->C_Prefs = Back;
  70.     else
  71.         strcpy( IE->ChipString, GetString( Gadgets[ GD_Chip ] ));
  72.     }
  73.  
  74.     CloseWnd( &Wnd, &GList );
  75. }
  76.  
  77. /*
  78.     C source code created by Interface Editor
  79.     Copyright © 1994-1996 by Simone Tellini
  80.  
  81.     Generator:  C.generator 37.0 (16.1.96)
  82.  
  83.     Copy registered to :  Simone Tellini
  84.     Serial Number      : #0
  85. */
  86.  
  87. /*
  88.    In this file you'll find empty  template  routines
  89.    referenced in the GUI source.  You  can fill these
  90.    routines with your code or use them as a reference
  91.    to create your main program.
  92. */
  93.  
  94. BOOL MsgKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  95. {
  96.     /*  Routine when "Intui_Message "'s activation key is pressed  */
  97.  
  98.     CheckedTag[1] = ( IE->C_Prefs & INTUIMSG ) ? FALSE : TRUE;
  99.     GT_SetGadgetAttrsA( Gadgets[ GD_Msg ], Wnd, NULL, (struct TagItem *)CheckedTag );
  100.  
  101.     /*  ...or return TRUE not to call the gadget function  */
  102.     return MsgClicked( Wnd, Gadgets, IE, Msg );
  103. }
  104.  
  105. BOOL ClickKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  106. {
  107.     /*  Routine when "Clicked _Ptr  "'s activation key is pressed  */
  108.  
  109.     CheckedTag[1] = ( IE->C_Prefs & CLICKED ) ? FALSE : TRUE;
  110.     GT_SetGadgetAttrsA( Gadgets[ GD_Click ], Wnd,
  111.             NULL, (struct TagItem *)CheckedTag );
  112.  
  113.     /*  ...or return TRUE not to call the gadget function  */
  114.     return ClickClicked( Wnd, Gadgets, IE, Msg );
  115. }
  116.  
  117. BOOL OkKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  118. {
  119.     /*  Routine when "_Ok"'s activation key is pressed  */
  120.  
  121.     /*  ...or return TRUE not to call the gadget function  */
  122.     return OkClicked( Wnd, Gadgets, IE, Msg );
  123. }
  124.  
  125. BOOL CancKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  126. {
  127.     /*  Routine when "_Cancel"'s activation key is pressed  */
  128.  
  129.     /*  ...or return TRUE not to call the gadget function  */
  130.     return CancClicked( Wnd, Gadgets, IE, Msg );
  131. }
  132.  
  133. BOOL HandlerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  134. {
  135.     /*  Routine when "IDCMP _Handler"'s activation key is pressed  */
  136.  
  137.     CheckedTag[1] = ( IE->C_Prefs & IDCMP_HANDLER ) ? FALSE : TRUE;
  138.     GT_SetGadgetAttrsA( Gadgets[ GD_Handler ], Wnd,
  139.             NULL, (struct TagItem *)CheckedTag );
  140.  
  141.     /*  ...or return TRUE not to call the gadget function  */
  142.     return HandlerClicked( Wnd, Gadgets, IE, Msg );
  143. }
  144.  
  145. BOOL KeyHandlerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  146. {
  147.     /*  Routine when "_Key Handler  "'s activation key is pressed  */
  148.  
  149.     CheckedTag[1] = ( IE->C_Prefs & KEY_HANDLER ) ? FALSE : TRUE;
  150.     GT_SetGadgetAttrsA( Gadgets[ GD_KeyHandler ], Wnd,
  151.             NULL, (struct TagItem *)CheckedTag );
  152.  
  153.     /*  ...or return TRUE not to call the gadget function  */
  154.     return KeyHandlerClicked( Wnd, Gadgets, IE, Msg );
  155. }
  156.  
  157. BOOL TemplateKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  158. {
  159.     /*  Routine when "_Template     "'s activation key is pressed  */
  160.     CheckedTag[1] = ( IE->C_Prefs & GEN_TEMPLATE ) ? FALSE : TRUE;
  161.     GT_SetGadgetAttrsA( Gadgets[ GD_Template ], Wnd,
  162.             NULL, (struct TagItem *)CheckedTag );
  163.  
  164.     /*  ...or return TRUE not to call the gadget function  */
  165.     return TemplateClicked( Wnd, Gadgets, IE, Msg );
  166. }
  167.  
  168. BOOL ToLowerKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  169. {
  170.     /*  Routine when "To Lo_wer     "'s activation key is pressed  */
  171.     CheckedTag[1] = ( IE->C_Prefs & TO_LOWER ) ? FALSE : TRUE;
  172.     GT_SetGadgetAttrsA( Gadgets[ GD_ToLower ], Wnd,
  173.             NULL, (struct TagItem *)CheckedTag );
  174.  
  175.     /*  ...or return TRUE not to call the gadget function  */
  176.     return ToLowerClicked( Wnd, Gadgets, IE, Msg );
  177. }
  178.  
  179. BOOL SmartStrKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  180. {
  181.     /*  Routine when "_Smart String"'s activation key is pressed  */
  182.     CheckedTag[1] = ( IE->C_Prefs & SMART_STR ) ? FALSE : TRUE;
  183.     GT_SetGadgetAttrsA( Gadgets[ GD_SmartStr ], Wnd,
  184.             NULL, (struct TagItem *)CheckedTag );
  185.  
  186.     /*  ...or return TRUE not to call the gadget function  */
  187.     return SmartStrClicked( Wnd, Gadgets, IE, Msg );
  188. }
  189.  
  190. BOOL NewTmpKeyPressed( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  191. {
  192.     CheckedTag[1] = ( IE->C_Prefs & ONLY_NEW_TMP ) ? FALSE : TRUE;
  193.     GT_SetGadgetAttrsA( Gadgets[ GD_NewTmp ], Wnd,
  194.             NULL, (struct TagItem *)CheckedTag );
  195.  
  196.     return NewTmpClicked( Wnd, Gadgets, IE, Msg );
  197. }
  198.  
  199. BOOL MsgClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  200. {
  201.     /*  Routine when "Intui_Message " is clicked  */
  202.  
  203.     IE->C_Prefs ^= INTUIMSG;
  204.  
  205.     return( 0 );
  206. }
  207.  
  208. BOOL ClickClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  209. {
  210.     /*  Routine when "Clicked _Ptr  " is clicked  */
  211.  
  212.     IE->C_Prefs ^= CLICKED;
  213.  
  214.     return( 0 );
  215. }
  216.  
  217. BOOL OkClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  218. {
  219.     /*  Routine when "_Ok" is clicked  */
  220.     return( -1 );
  221. }
  222.  
  223. BOOL CancClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  224. {
  225.     /*  Routine when "_Cancel" is clicked  */
  226.     return( 1 );
  227. }
  228.  
  229. BOOL HandlerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  230. {
  231.     /*  Routine when "IDCMP _Handler" is clicked  */
  232.  
  233.     IE->C_Prefs ^= IDCMP_HANDLER;
  234.  
  235.     if( IE->C_Prefs & IDCMP_HANDLER ) {
  236.  
  237.         IE->C_Prefs &= ~( CLICKED | INTUIMSG );
  238.  
  239.         MsgKeyPressed( Wnd, Gadgets, IE, Msg );
  240.         ClickKeyPressed( Wnd, Gadgets, IE, Msg );
  241.     }
  242.  
  243.     return( 0 );
  244. }
  245.  
  246. BOOL KeyHandlerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  247. {
  248.     /*  Routine when "_Key Handler  " is clicked  */
  249.  
  250.     IE->C_Prefs ^= KEY_HANDLER;
  251.  
  252.     if( IE->C_Prefs & KEY_HANDLER ) {
  253.  
  254.         IE->C_Prefs &= ~( CLICKED | INTUIMSG );
  255.  
  256.         MsgKeyPressed( Wnd, Gadgets, IE, Msg );
  257.         ClickKeyPressed( Wnd, Gadgets, IE, Msg );
  258.     }
  259.  
  260.     return( 0 );
  261. }
  262.  
  263. BOOL TemplateClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  264. {
  265.     /*  Routine when "_Template     " is clicked  */
  266.  
  267.     IE->C_Prefs ^= GEN_TEMPLATE;
  268.  
  269.     return( 0 );
  270. }
  271.  
  272. BOOL ToLowerClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  273. {
  274.     /*  Routine when "To Lo_wer     " is clicked  */
  275.  
  276.     IE->C_Prefs ^= TO_LOWER;
  277.  
  278.     return( 0 );
  279. }
  280.  
  281. BOOL ChipClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  282. {
  283.     /*  Routine when "_UWORD chip:" is clicked  */
  284.     return( 0 );
  285. }
  286.  
  287. BOOL SmartStrClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  288. {
  289.     /*  Routine when "_Smart String" is clicked  */
  290.  
  291.     IE->C_Prefs ^= SMART_STR;
  292.  
  293.     return( 0 );
  294. }
  295.  
  296. BOOL NewTmpClicked( struct Window *Wnd, struct Gadget *Gadgets[], struct IE_Data *IE, struct IntuiMessage *Msg )
  297. {
  298.     IE->C_Prefs ^= ONLY_NEW_TMP;
  299.  
  300.     return( 0 );
  301. }
  302. ///
  303.  
  304.